#define _XOPEN_SOURCE
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	struct tm *tm_ptr, timestruct;
	time_t  the_time;
	char buff[256];
	char *result;

	(void)time(&the_time);
	tm_ptr=localtime(&the_time);
	
	strftime(buff,256, "%A %d %B, %I:%S %p", tm_ptr);
	
	printf("strftime gives:%s\n", buff);

	strcpy(buff,"Thu 26 July 2007, 17:53 will be fine");
	
	printf("calling strptime with: %s \n", buff);
	
	tm_ptr=&timestruct;
	
	result=strptime(buff, "%a %d %b %Y, %R", tm_ptr);
	
	printf("strptime consumed up to : %s\n", result);
	
	printf("strptime gives:\n");
	
	printf("date: %02d/%02d/%02d\n", tm_ptr->tm_year, tm_ptr->tm_mon+1, tm_ptr->tm_mday);

	printf("time: %02d:%02d \n", tm_ptr->tm_hour, tm_ptr->tm_min);

	exit(0);

}
